package com.example.export.job;

import com.example.export.service.DcAppService;
import com.example.export.util.SpringBeanFactory;
import com.example.export.vo.DcAppGotoByVo;
import com.example.export.vo.DcAppOrderPayDetail;
import com.example.export.vo.DcAppSearchCacheVo;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

/**
 * @author dangwen1
 * @date 2022年02月25日 15:31
 * @description
 */
@Slf4j
public class DcAppJob extends QuartzJobBean {

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) {
        DcAppService dcAppService = SpringBeanFactory.getBean(DcAppService.class);
        DcAppGotoByVo dcAppGotoByVo = dcAppService.getValue("dcAppGotoByVo");
        if (Objects.nonNull(dcAppGotoByVo) && Objects.nonNull(dcAppGotoByVo.getSetPrice())
                && Objects.nonNull(dcAppGotoByVo.getCommodityName()) ){
            List<DcAppOrderPayDetail> dcAppOrderPayDetails = dcAppService.gotoBuy(dcAppGotoByVo);
            if (!CollectionUtils.isEmpty(dcAppOrderPayDetails)) {
                dcAppService.setOrderList(dcAppOrderPayDetails);
            }
        }
//        System.out.println("quartz executing..." + LocalDateTime.now().getSecond());
    }
}
